<template>
    <view>
        <uni-segmented-control :current="current" :values="items" 
		@clickItem="onClickItem" style-type="button" active-color="#CCCCCC"></uni-segmented-control>
        <view class="content" >
            <view v-show="current === 0" >
                <lampList v-bind:lamps = "lamps"></lampList>
            </view>
            <view v-show="current === 1">
                 <lampList v-bind:lamps = "lamps"></lampList>
            </view>
            <view v-show="current === 2">
                 <lampList v-bind:lamps = "lamps"></lampList>
            </view>
        </view>
    </view>
</template>

<script>
	import lampList from "../lampList/lampList.vue"
	export default {
	    components: {uniSegmentedControl,lampList},
	    data() {
	        return {
	            items: ['工作正常','异常跳闸','通讯断开'],
	            current: 0,
				queryParam:{
					page:1,
					rows:20,
					keyword:'',
					status:'',
					type:'',
					sort:'+id'
				},
				lamps:[]
	        }
	    },
		onLoad() {
				 console.log('onload')
			this.loadList();
		},
	    methods: {
	        onClickItem(e) {
	            if (this.current !== e.currentIndex) {
	                this.current = e.currentIndex;
					this.loadList(e.currentIndex)
	            }
	        },
		loadList(sta){
			let _this = this;
			let token =''
			uni.getStorage({
				key:'token',
				success(e){
					 _this.queryParam.token = e.data;
				}
			})
			_this.queryParam.status = sta;
			console.log(_this.queryParam)
			uni.request({
			    url: this.$baseUrl+'dev/list', //仅为示例，并非真实接口地址。
				 method :'POST',
				 header:{
					 'content-type':'application/x-www-form-urlencoded'
				 },
			    data: _this.queryParam,
			    success: function(res) {
					console.log(res.data.data.list);
					_this.lamps = res.data.data.list;
			    }
			})
		}
	    }
	}
</script>

<style lang="scss">
	.content {
		
	}
</style>
